package nina.yiyou.attendance.s10merge.compute

import java.time.LocalDateTime
import java.time.temporal.ChronoUnit

class LateMinuteCalculator {

  LateMinuteCalculator(AttendDetailMerger.PunchDay day, LocalDateTime punchIn, LocalDateTime latePoint) {
    _day = day
    _punchIn = punchIn
    _latePoint = latePoint
  }

  int calc() {
    if (!_punchIn) {
      return 0
    }
    if (_day.isPunchFree()) {
      return 0
    }
    return Math.max(_latePoint.until(_punchIn, ChronoUnit.MINUTES), 0)
  }

  private final AttendDetailMerger.PunchDay _day

  private final LocalDateTime _punchIn
  private final LocalDateTime _latePoint
}
